//
// Created by sjjmw on 2/23/2022.
//

#ifndef LEETCODE__17_H
#define LEETCODE__17_H
#include "iostream"
int main(){
    int n;
    while (scanf("%d",&n) != EOF /* condition */)
    {
        bool found=false;
        for(int i=7;i<=1000000;i+=10){
            int ws=1;
            int cpy=i;
            while(cpy>0){
                cpy/=10;
                ws*=10;
            }
            ws/=10;
//            if(i==142857){
//                auto a=i/10+7*ws;
//
//                        a+1;
//            }
            if((i/10+7*ws)==n*i){

                printf("%d\n",i);
                found= true;
                break;

            }
        }
        if(!found){
            printf("No\n");
        }
    }
    return 0;
}
#endif //LEETCODE__17_H
